<?php

namespace App\Logic;

use App\Exceptions\ApiException;
use App\Service\BookingService;

class BookingLogic
{
    protected BookingService $service;

    public function __construct()
    {
        $this->service = new BookingService();
    }

    /**
     * 获取拼本列表
     *
     * @param array $params
     * @return array
     */
    public function list(array $params): array
    {
        return $this->service->list($params);
    }

    /**
     * 新增拼本
     *
     * @param array $params
     * @return array
     */
    public function create(array $params): array
    {
        return $this->service->create($params);
    }

    /**
     * 我发布的列表
     *
     * @param array $params
     * @return array
     */
    public function myList(array $params): array
    {
        return $this->service->myList($params);
    }

    /**
     * 检查拼本是否存在
     *
     * @param int    $id
     * @param string $user_id
     * @return bool
     */
    public function checkExists(int $id, string $user_id): bool
    {
        return $this->service->checkExists($id, $user_id);
    }

    /**
     * 修改拼本
     *
     * @param array $params
     * @return array
     * @throws ApiException
     */
    public function update(array $params): array
    {
        return $this->service->update($params);
    }
}
